package com.qf.controller;

import com.qf.entity.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @author Ypl
 * @version V1.0
 * @Project OctoberAndNovember
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/11/2 10:40
 */
@RestController
public class GoodsController {
    @Value("${server.port}")
    private int port;

    @RequestMapping("/query")
    public String queryGoods(){
        return "全部商品"+port;
    }

    /**
     * 模拟请求方法不同
     */
    @GetMapping("/query1")
    public String queryGoods1(){
        return "全部商品"+port;
    }

    /**
     * 模拟get传参
     *  接收参数的时候需要 + @RequestParam 才可以接收到
     */
    @GetMapping("/query2")
    public String queryGoods2(@RequestParam int id, @RequestParam String name){
        return "success";
    }

    @GetMapping("/query3/{id}")
    public String queryGoods3(@PathVariable(value = "id") Integer id){
        System.out.println(id);
        return "success3";
    }

    /**
     * 测试post传参
     *
     */
    @PostMapping("/query4")
    public String queryGoods4(@RequestBody User user){
        System.out.println(user);
        return "success4";
    }

}
